cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
project(cloud_storage_service_v2 VERSION 1.0.0 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# 将编译输出目录设置到 build/bin
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)

option(ENABLE_DEBUG "Enable debug log output" ON) # 开发时默认为 ON

# 头文件目录
include_directories(
    ${CMAKE_CURRENT_SOURCE_DIR}/include
)           

add_library(${PROJECT_NAME} STATIC
    src/common/config.cpp
    src/common/response.cpp
    src/database/db_connection.cpp
    src/database/file_dao.cpp
    src/database/user_dao.cpp
    src/handlers/file_handler.cpp
    src/handlers/user_handler.cpp
    src/utils/crypto.cpp
    src/utils/file_utils.cpp
    src/utils/token.cpp
    src/utils/oss_client_manager.cpp
)



# 链接库
target_link_libraries(${PROJECT_NAME} PRIVATE
    ssl
    crypto
    mysqlclient
    pthread
    workflow
    alibabacloud-oss-cpp-sdk
    curl
)

add_executable(server_v2 src/main.cpp)           

if(ENABLE_DEBUG)
    message(STATUS "Debug mode is ON")
    target_compile_definitions(server_v2 PRIVATE DEBUG_MODE)
endif()

target_link_libraries(server_v2 PRIVATE ${PROJECT_NAME})

target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -g)


